package com.javapda.c328r.command.impl;

import com.javapda.c328r.command.ComediaCommandId;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.EqualsBuilder;

public class AbstractComediaCommandId implements ComediaCommandId {

	private int[] data = new int[2];

	public boolean equals(final Object other) {
		if (!(other instanceof AbstractComediaCommandId))
			return false;
		AbstractComediaCommandId castOther = (AbstractComediaCommandId) other;
		return new EqualsBuilder().append(data, castOther.data).isEquals();
	}

	public int hashCode() {
		return new HashCodeBuilder().append(data).toHashCode();
	}
	public String toString() {
		return new ToStringBuilder(this)
					.append("data", data)
					.append("idHex", getDataAsHex())
					.toString();
	}
	public String getDataAsHex() {
		StringBuilder sb = new StringBuilder();
		sb.append(Integer.toHexString(data[0]));
		sb.append(Integer.toHexString(data[1]));
		return sb.toString();
	}

	AbstractComediaCommandId(int part1, int part2) {
		data[0] = part1 ;
		data[1] = part2 ;
	}
	
	public int[] getId() {
		return data;
	}

	public int getIdPart1() {
		return data[0];
	}

	public int getIdPart2() {
		return data[1];
	}

}
